//
//  MainViewController.m
//  Chat
//
//  Created by 任伟 on 16/1/3.
//  Copyright © 2016年 任伟. All rights reserved.
//

#import "MainViewController.h"
#import "HomeViewController.h"
#import "NewsViewController.h"
#import "ReminderMainVC.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // 添加自控制器
    [self addChildViewControllers];
    
}

#pragma mark - 设置自控制
- (void)addChildViewControllers {

    // 设置 tabBar 的 tintColor
    self.tabBar.tintColor = [UIColor purpleColor];
    
    // 添加子控制器
    [self addChildViewController:[[HomeViewController alloc] init] title:@"聊天" imageName:@"tabbar_home"];
    [self addChildViewController:[[NewsViewController alloc] init] title:@"新闻" imageName:@"tabbar_message_center"];
    [self addChildViewController:[[ReminderMainVC alloc] init] title:@"提醒" imageName:@"tabbar_discover"];
    
}

/// 设置自控制器
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title imageName:(NSString *)imageName {

    childController.title = title;
    
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    NSString *selectedImageName = [NSString stringWithFormat:@"%@_selected",imageName];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 添加子控制器
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childController];
    
    [self addChildViewController:nav];
    
}


@end
